layui.use(['laydate','form','table','layer','laytpl','common'], function(){
	var laydate = layui.laydate,form = layui.form,table = layui.table,layer = layui.layer,laytpl = layui.laytpl,common = layui.common;
	/*开始时间*/
	laydate.render({
	  	elem: '#start' //指定元素
	});
	/*结束时间*/
	laydate.render({
	  	elem: '#end' //指定元素
	});
	/*@条件*/
	var ids = $('input[name="ids"]').val()
	var type = $('input[name="type"]').val()
	var where = {ids: ids, type: type};
	/*@初始化table*/
	var tableObj = table.render({
	    elem: '#table-list',
	    url: '/staff/staff/shop_list', //数据接口
	    page: false, //开启分页
	    where: where,
	    limits: false,
	    cols: [[ //表头
	    	{field: 'admin_sn', title: '员工编号'},
	    	{field: 'nkname', title: '姓名'},
	    	{field: 'shop_name', title: '所属门店'},
	    	{field: 'title', title: '员工职位'},
	    	{field: 'order_money', title: '销售总额(元)', toolbar: '<div>{{d.count_order.order_money}}</div>'},
	    	{field: 'buying', title: '销售总成本(元)', toolbar: '<div>{{d.count_order.buying}}</div>'},
	    	{field: 'refund_money', title: '退款总额(元)', toolbar: '<div>{{d.count_order.refund_money}}</div>'},
	    	{field: 'recal_money', title: '召回总额(元)', toolbar: '<div>{{d.count_order.recal_money}}</div>'},
	    	{field: 'sale', title: '销售总盈利(元)', toolbar: '<div>{{d.count_order.sale}}</div>'},
	    	{field: 'sale_bonus', title: '销售总提成(元)', toolbar: '<div>{{d.count_order.sale_bonus}}</div>'},
	    	{field: 'turn_bonus', title: '营业额总提成(元)', toolbar: '<div>{{d.count_order.turn_bonus}}</div>'}
	    ]],
	    parseData: function(res){
	    	console.log(res)
	    	for(var i = 0;i < res.data.length;++i){
	    		res.data[i].order_money = res.data[i].count_order.order_money
		    	res.data[i].buying = res.data[i].count_order.buying
		    	res.data[i].refund_money = res.data[i].count_order.refund_money
		    	res.data[i].recal_money = res.data[i].count_order.recal_money
		    	res.data[i].sale = res.data[i].count_order.sale
		    	res.data[i].sale_bonus = res.data[i].count_order.sale_bonus
		    	res.data[i].turn_bonus = res.data[i].count_order.turn_bonus
	    	}
	    	console.log(res.data)
	    	exportData = res.data
	    },
	});
	/*@导出数据处理*/
	common.list.handleData = function(res){
		for(var i = 0;i < res.data.length;++i){
    		res.data[i].order_money = res.data[i].count_order.order_money
	    	res.data[i].buying = res.data[i].count_order.buying
	    	res.data[i].refund_money = res.data[i].count_order.refund_money
	    	res.data[i].recal_money = res.data[i].count_order.recal_money
	    	res.data[i].sale = res.data[i].count_order.sale
	    	res.data[i].sale_bonus = res.data[i].count_order.sale_bonus
	    	res.data[i].turn_bonus = res.data[i].count_order.turn_bonus
    	}
    	return res.data
	}
	/*@查询*/
	common.list.search('search', tableObj)
	/*@导出*/
	common.list.excel('export', '/staff/staff/shop_list', tableObj, '员工销售业绩', 'xls')

});